<template>
  <div>
    <van-field v-model="text" :label="label" :placeholder="placeholder" :rule="rules" :type="type"/>
  </div>
</template>

<script>
export default {
  name: 'LoginText',
  props: ['label', 'type', 'placeholder', 'rules'],
  data() {
    return {
      text: ''
    }
  },
  methods: {
    handlerulg() {
      const regex = new RegExp(this.rules)
      if (regex.test(this.text)) {
        this.$emit('inputChange', this.text)
      }
    }
  },
  watch: {
    text() {
      this.handlerulg()
    }
  }
}
</script>

<style scoped>

</style>
